//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.jpgolay.me;

import java.awt.Dimension;
import javax.swing.*;

public class AppToolBarGUI extends JToolBar {

    public AppToolBarGUI() {
        piecesJButton = null;
        searchJButton = null;
        stockJButton = null;
        salespersonManagerJButton = null;
        statisticsJButton = null;
        makingJButton = null;
        initialize();
    }

    public AppToolBarGUI(int orientation) {
        super(orientation);
        piecesJButton = null;
        searchJButton = null;
        stockJButton = null;
        salespersonManagerJButton = null;
        statisticsJButton = null;
        makingJButton = null;
    }

    public AppToolBarGUI(String name) {
        super(name);
        piecesJButton = null;
        searchJButton = null;
        stockJButton = null;
        salespersonManagerJButton = null;
        statisticsJButton = null;
        makingJButton = null;
    }

    public AppToolBarGUI(String name, int orientation) {
        super(name, orientation);
        piecesJButton = null;
        searchJButton = null;
        stockJButton = null;
        salespersonManagerJButton = null;
        statisticsJButton = null;
        makingJButton = null;
    }

    private void initialize() {
        setSize(175, 25);
        add(getPiecesJButton());
        add(getSearchJButton());
        add(getStockJButton());
        add(getMakingJButton());
        add(getSalespersonManagerJButton());
        add(getStatisticsJButton());
    }

    private JButton getPiecesJButton() {
        if (piecesJButton == null) {
            piecesJButton = new JButton();
            piecesJButton.setPreferredSize(new Dimension(18, 18));
            piecesJButton.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/me/images/pieces18x18.png")));
            piecesJButton.setToolTipText("PIECES");
            piecesJButton.setBorderPainted(false);
            piecesJButton.setContentAreaFilled(false);
        }
        return piecesJButton;
    }

    private JButton getSearchJButton() {
        if (searchJButton == null) {
            searchJButton = new JButton();
            searchJButton.setPreferredSize(new Dimension(18, 18));
            searchJButton.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/me/images/search18x18.png")));
            searchJButton.setToolTipText("RECHERCHES");
            searchJButton.setBorderPainted(false);
            searchJButton.setContentAreaFilled(false);
        }
        return searchJButton;
    }

    private JButton getStockJButton() {
        if (stockJButton == null) {
            stockJButton = new JButton();
            stockJButton.setPreferredSize(new Dimension(18, 18));
            stockJButton.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/me/images/stock18x18.png")));
            stockJButton.setToolTipText("STOCK");
            stockJButton.setBorderPainted(false);
            stockJButton.setContentAreaFilled(false);
        }
        return stockJButton;
    }

    private JButton getSalespersonManagerJButton() {
        if (salespersonManagerJButton == null) {
            salespersonManagerJButton = new JButton();
            salespersonManagerJButton.setPreferredSize(new Dimension(18, 18));
            salespersonManagerJButton.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/me/images/salesperson18x18.png")));
            salespersonManagerJButton.setToolTipText("COMMERCIAUX");
            salespersonManagerJButton.setBorderPainted(false);
            salespersonManagerJButton.setContentAreaFilled(false);
        }
        return salespersonManagerJButton;
    }

    private JButton getStatisticsJButton() {
        if (statisticsJButton == null) {
            statisticsJButton = new JButton();
            statisticsJButton.setPreferredSize(new Dimension(18, 18));
            statisticsJButton.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/me/images/statistics18x18.png")));
            statisticsJButton.setToolTipText("STATISTIQUES");
            statisticsJButton.setBorderPainted(false);
            statisticsJButton.setContentAreaFilled(false);
        }
        return statisticsJButton;
    }

    private JButton getMakingJButton() {
        if (makingJButton == null) {
            makingJButton = new JButton();
            makingJButton.setPreferredSize(new Dimension(18, 18));
            makingJButton.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/me/images/build18x18.png")));
            makingJButton.setToolTipText("FABRICATION");
            makingJButton.setBorderPainted(false);
            makingJButton.setContentAreaFilled(false);
        }
        return makingJButton;
    }

    public JButton getPieces() {
        return getPiecesJButton();
    }

    public JButton getSearch() {
        return getSearchJButton();
    }

    public JButton getStock() {
        return getStockJButton();
    }

    public JButton getSalespersonManager() {
        return getSalespersonManagerJButton();
    }

    public JButton getStatistics() {
        return getStatisticsJButton();
    }

    public JButton getMaking() {
        return getMakingJButton();
    }

    public void setEnabledAll(boolean b) {
        getPiecesJButton().setEnabled(b);
        getSearchJButton().setEnabled(b);
        getStockJButton().setEnabled(b);
        getSalespersonManagerJButton().setEnabled(b);
        getStatisticsJButton().setEnabled(b);
        getMakingJButton().setEnabled(b);
    }
    private JButton piecesJButton;
    private JButton searchJButton;
    private JButton stockJButton;
    private JButton salespersonManagerJButton;
    private JButton statisticsJButton;
    private JButton makingJButton;
}
